<?php
namespace App\Admin\Controllers\Traits\WxSettingTraits;

use App\Wen\Utils\FieldUtils;
use App\Wen\Utils\GatewayUtils;
use App\Wen\Utils\Settings;
use App\Wen\Utils\SiteUtils;
use Dcat\Admin\Form\NestedForm;
use Dcat\Admin\Layout\Content;
use Dcat\Admin\Widgets\Form;
use Dcat\Admin\Widgets\Tooltip;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;

trait formPageNoticeTrait{
    public function index_pagenotice(Content $content)
    {
        return $content->title('消息配置')
//            ->body($this->buildPreviewButton())
//            ->body($this->newline())
            ->body(
                <<<HTML
<div class="card">{$this->form_pagenotice()->render()}</div>
HTML
            );
    }
    protected function form_pagenotice(){
        $form = new Form();
        $form->confirm('您确定要提交表单吗？', 'content');
        $form->disableResetButton();

        $form->tab('运营', function (Form $form) {
            global $__MINI_GLOBAL_TENANT_ID__;
            if($__MINI_GLOBAL_TENANT_ID__ === 0){
                $form->select('app_notice_assistant_user', '小秘书通知')->options(function ($id) {
                    $user = \App\Models\User\WxUser::find($id);
                    if ($user) {
                        return [$user->id => $user->user_name];
                    }
                })->help('小队长账号为<span style="color: red;">机器人账号</span>，请将小队长账号设置为一个不用的账号，因为消息数量会特别膨大，该账号对全站都有消息记录')->ajax('select/users')->default(Settings::get('app_notice_assistant_user', ''));

            }

            $form->textarea('app_notice_assistant_first', '第一次注册交流')->default('区别于第一次注册通知，这是使用小秘书身份进行聊天，可以介绍一下小秘书')->default(Settings::get('app_notice_assistant_first', '您好，很高兴认识您，自我介绍一下，我是您的专职小秘书，以后有些事情，由我负责通知您哦！', true));

            if($__MINI_GLOBAL_TENANT_ID__ === 0){
                $form->divider();
                $form->select('app_notice_review_user', '审核推送账号')->options(function ($id) {
                    $user = \App\Models\User\WxUser::find($id);
                    if ($user) {
                        return [$user->id => $user->user_name];
                    }
                })->help('推送账号为<span style="color: red;">机器人账号</span>，目前会推送包括：1、笔记 2、评论 3、组局 4、选票 5、选票选手 6、闲置审核 7、圈子审核 8、学生认证 9、身份认证')->ajax('select/users')->default(Settings::get('app_notice_review_user', ''));
            }

        });

        global $__MINI_GLOBAL_TENANT_ID__;
        if($__MINI_GLOBAL_TENANT_ID__ === 0){
            $form->tab('模板消息', function (Form $form) {
                $form->html(function () {
                    return '';
                }, '<b>一、服务号模板消息</b>');
                $form->html(function () {
                    return '<div style="background-color: powderblue;color: #414750;padding: 10px;border-radius: 5px;">tips：若下方配置了模板则代表你打开了服务号模板消息通知</div>';
                }, '');
                $res2 = __system__paycode__tip__(2);
                Tooltip::make('.mini_global_admin_open_not_support_tip')
                    ->bottom()
                    ->title($res2['tip']);
                $form->text('template_message_notice_id', '消息模板id')->help($res2['text'].'注意：公众号要先关联小程序，<a href="https://img.minisns.cn/default/template_message.png" target="_blank">查看教程</a>-------------><a href="'.env('APP_URL').'/api/v1/three/safe/templete/message/add?access_token='.Settings::get('mini_access_token', '').'&key1=闻&key2=爱你'.'" target="_blank">点击这里测试发送</a>')->default(Settings::get('template_message_notice_id', ''));
                $form->multipleSelect('template_message_notice_black_list', '不通知名单')->options([
                    '1000' => '1000: 默认图标',
                    '1001' => '1001: 注册欢迎',
                    '1002' => '1002: 系统检测封号通知',
                    '1003' => '1003: 管理员手动操作封号通知',
                    '2001' => '2001: 笔记审核通知',
                    '2002' => '2002: 笔记被转移通知',
                    '2003' => '2003: 笔记收到喜欢',
                    '2004' => '2004: 笔记被管理删除通知',
                    '2005' => '2005: 笔记收到评论通知',
                    '2006' => '2006: 笔记收到收藏通知',
                    '2007' => '2007: 笔记被转发通知',
                    '2008' => '2008: 视频审核结果',
                    '3001' => '3001: 评论审核通知',
                    '3002' => '3002: 评论收到回复',
                    '3003' => '3003: 评论收到爱心',
                    '4001' => '4001: 申请注销成功通知',
                    '4002' => '4002: 续费会员成功',
                    '4003' => '4003: 开通会员成功',
                    '4004' => '4004: 用户新增了粉丝',
                    '4005' => '4005: 认证结果通知',
                    '4006' => '4006: 反馈处理通知',
                    '4007' => '4007: 自动关注圈子',
                    '4008' => '4008: 账号注销取消通知',
                    '4009' => '4009: 用户被笔记@',
                    '4010' => '4010: 用户被评论@',
                    '4011' => '4011: 学生认证结果',
                    '5001' => '5001: 创建圈子审核通知',
                    '5002' => '5002: 创建圈子收获粉丝',
                    '6001' => '6001: 商品发货通知',
                    '6002' => '6002: 商品售后通知',
                    '6003' => '6003: 商品自动确认收货通知',
                    '6004' => '6004: 店铺审核结果',
                    '6005' => '6005: 店铺保证金变动',
                    '6006' => '6006: 商家新订单',
                    '7001' => '7001: 提现到账通知',
                    '7002' => '7002: 提现异常通知',
                    '7003' => '7003: 金币到账通知',
                    '7004' => '7004: ' . env('circle_user_call', '圈主') . '分成奖励',
                    '7005' => '7005: 余额变动提醒',
                    '8001' => '8001: 创建选票审核结果',
                    '8002' => '8002: 报名选票选手审核',
                    '9001' => '9001: 创建俱乐部审核结果',
                    '9002' => '9002: 组局活动审核结果',
                    '9003' => '9003: 组局活动即将开始',
                    '9004' => '9004: 组局活动已结束，可上传图集',
                    '9005' => '9005: 参与的组局活动被下架'
                ])->default(Settings::get('template_message_notice_black_list', []));
                $form->divider();
                $form->html(function () {
                    return '';
                }, '<b>一、小程序订阅消息</b>');
                $form->text('mini_template_message_comment_add', '新的评论提醒')->placeholder('WEBpC52jjitwG4WgPKsckJaj473vJBrBhHApzy7L3bI')->help('<a href="https://img.mini.minisns.cn/images/bg/comment_add.jpg" target="_blank">查看教程</a>')->default(Settings::get('mini_template_message_comment_add', ''));
                $form->text('mini_template_message_comment_reply', '评论回复通知')->placeholder('ZqkOoIE4QQq3Q0I04kx5lf5-CRFGbAEuCKvBtnOWlvc')->help('<a href="https://img.mini.minisns.cn/images/bg/comment_reply.jpg" target="_blank">查看教程</a>')->default(Settings::get('mini_template_message_comment_reply', ''));
                $form->text('mini_template_message_exceptional', '收到赞赏通知')->placeholder('WEBpC52jjitwG4WgPKsckJaj473vJBrBhHApzy7L3bI')->help('<a href="https://img.mini.minisns.cn/images/bg/exceptional.jpg" target="_blank">查看教程</a>')->default(Settings::get('mini_template_message_exceptional', ''));
                $form->text('mini_template_message_beliked', '收到点赞通知')->placeholder('WEBpC52jjitwG4WgPKsckJaj473vJBrBhHApzy7L3bI')->help('<a href="https://img.mini.minisns.cn/images/bg/like.jpg" target="_blank">查看教程</a>')->default(Settings::get('mini_template_message_beliked', ''));
                $form->text('mini_template_message_withdrawal', '提现结果通知')->placeholder('WEBpC52jjitwG4WgPKsckJaj473vJBrBhHApzy7L3bI')->help('<a href="https://img.mini.minisns.cn/images/bg/withdrawal.jpg" target="_blank">查看教程</a>')->default(Settings::get('mini_template_message_withdrawal', ''));
                $form->text('mini_template_message_authentication', '认证审核通知')->placeholder('WEBpC52jjitwG4WgPKsckJaj473vJBrBhHApzy7L3bI')->help('<a href="https://img.mini.minisns.cn/images/bg/authentication.jpg" target="_blank">查看教程</a>')->default(Settings::get('mini_template_message_authentication', ''));
            });
        }


        $form->tab('消息tab', function (Form $form) {
            global $__MINI_GLOBAL_TENANT_ID__;
            if($__MINI_GLOBAL_TENANT_ID__ === 0){
                $form->html(function () {
                    return '';
                }, '<b>一、图标配置</b>');
                $form->radio('app_notice_mp_follow', '公众号关注入口')->options([0 => '关闭', 1 => '开启'])->help('需要你认证微信开放平台，并且开放平台绑定好了公众号，小程序')->default(Settings::get('app_notice_mp_follow', 1));
                $form->radio('app_notice_img_style', '图标排列')->options([0=>'横向摆放', 1=>'竖向摆放'])->default(Settings::get('app_notice_img_style', 0));
                $form->image('app_notice_img_system', '[系统通知]图标')->help('<a href="https://img.mini.minisns.cn/images/notice/app_notice_img_system.png" download="app_share_vip_img.jpg" target="_blank" style="color: steelblue">点击下载默认图</a>')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_img_system', 'https://img.mini.minisns.cn/images/notice/app_notice_img_system.png'));
                $form->image('app_notice_img_like', '[赞和收藏]图标')->help('<a href="https://img.mini.minisns.cn/images/notice/app_notice_img_like.png" download="app_share_vip_img.jpg" target="_blank" style="color: steelblue">点击下载默认图</a>')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_img_like', 'https://img.mini.minisns.cn/images/notice/app_notice_img_like.png'));
                $form->image('app_notice_img_comment', '[评论和充电]图标')->help('<a href="https://img.mini.minisns.cn/images/notice/app_notice_img_comment.png" download="app_share_vip_img.jpg" target="_blank" style="color: steelblue">点击下载默认图</a>')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_img_comment', 'https://img.mini.minisns.cn/images/notice/app_notice_img_comment.png'));
                $form->image('app_notice_img_servicer', '[官方客服]图标')->help('<a href="https://img.mini.minisns.cn/images/notice/app_notice_img_servicer.png" download="app_share_vip_img.jpg" target="_blank" style="color: steelblue">点击下载默认图</a>')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_img_servicer', 'https://img.mini.minisns.cn/images/notice/app_notice_img_servicer.png'));
                $form->image('app_notice_img_circle', '[关注圈子]图标')->help('<a href="https://img.mini.minisns.cn/images/notice/app_notice_img_cirlce.png" download="app_share_vip_img.jpg" target="_blank" style="color: steelblue">点击下载默认图</a>')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_img_circle', 'https://img.mini.minisns.cn/images/notice/app_notice_img_cirlce.png'));
                $form->divider();
                $form->html(function () {
                    return '';
                }, '<b>二、App客服</b>');
            }

            $form->html(function () {
                return '<div style="background-color: powderblue;color: #414750;padding: 10px;border-radius: 5px;">1、小程序使用微信小程序客服（你可以在微信公众平台找到客服配置，把自己的微信号配置成客服，就可以收到客户的消息提醒）<br/>2、App客服可自定义跳转类型，推荐的是企业微信客服</div>';
            }, '');
            $form->radio('app_notice_img_servicer_target_type', '跳转类型')->options(FieldUtils::getUrlTypes())->default(Settings::get('app_notice_img_servicer_target_type', 0, true));
            $form->text('app_notice_img_servicer_target_id', '跳转id')->help('怎么填请看<a href="https://doc.minisns.cn/doc/44/" target="_blank">路径大全</a>')->default(Settings::get('app_notice_img_servicer_target_id', '', true));
            $form->radio('app_notice_img_servicer_mp_servicer', '小程序客服')->options([0=>'与App保持一致', 1=>'微信小程序客服'])->default(Settings::get('app_notice_img_servicer_mp_servicer', 0, true));
        });

        if($__MINI_GLOBAL_TENANT_ID__ === 0){
            $form->tab('消息图标', function (Form $form) {
                $form->html(function () {
                    return '<div style="background-color: powderblue;color: #414750;padding: 10px;border-radius: 5px;">小提示: 下面是系统消息页面的图标配置，官方暂时也没有那么多图标，如果有可以分享到素材圈，谢谢</div>';
                }, '');

                $form->row(function ($form) {
                    $form->html(function () {
                        return '';
                    }, '<b>一、全局相关</b>');
                });
                $form->row(function ($form) {
                    $form->width(2)->image('app_notice_type_icon_1000', '1000、默认图标')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_type_icon_1000', ''));
                    $form->width(2)->image('app_notice_type_icon_1001', '1001、注册欢迎')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_type_icon_1001', ''));
                    $form->width(2)->image('app_notice_type_icon_1002', '1002、系统检测封号通知')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_type_icon_1002', ''));
                    $form->width(2)->image('app_notice_type_icon_1003', '1003、管理员手动操作封号通知')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_type_icon_1003', ''));
                });

                $form->divider();

                $form->row(function ($form) {
                    $form->html(function () {
                        return '';
                    }, '<b>二、笔记相关</b>');
                });

                $form->row(function ($form) {
                    $form->width(2)->image('app_notice_type_icon_2001', '2001、笔记审核通知')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_type_icon_2001', ''));
                    $form->width(2)->image('app_notice_type_icon_2002', '2002、笔记被转移通知')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_type_icon_2002', ''));
                    $form->width(2)->image('app_notice_type_icon_2003', '2003、笔记收到喜欢')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_type_icon_2003', ''));
                    $form->width(2)->image('app_notice_type_icon_2004', '2004、笔记被管理删除通知')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_type_icon_2004', ''));
                    $form->width(2)->image('app_notice_type_icon_2005', '2005、笔记收到评论通知')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_type_icon_2005', ''));
                    $form->width(2)->image('app_notice_type_icon_2006', '2006、笔记收到收藏通知')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_type_icon_2006', ''));
                    $form->width(2)->image('app_notice_type_icon_2007', '2007、笔记被转发通知')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_type_icon_2007', ''));
                    $form->width(2)->image('app_notice_type_icon_2008', '2008、视频审核结果')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_type_icon_2008', ''));
                });

                $form->divider();

                $form->row(function ($form) {
                    $form->html(function () {
                        return '';
                    }, '<b>三、评论相关</b>');
                });
                $form->row(function ($form) {
                    $form->width(2)->image('app_notice_type_icon_3001', '3001、评论审核通知')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_type_icon_3001', ''));
                    $form->width(2)->image('app_notice_type_icon_3002', '3002、评论收到回复')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_type_icon_3002', ''));
                    $form->width(2)->image('app_notice_type_icon_3003', '3003、评论收到爱心')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_type_icon_3003', ''));
                });
                $form->divider();
                $form->row(function ($form) {
                    $form->html(function () {
                        return '';
                    }, '<b>四、用户相关</b>');
                });
                $form->row(function ($form) {
                    $form->width(2)->image('app_notice_type_icon_4001', '4001、申请注销成功通知')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_type_icon_4001', ''));
                    $form->width(2)->image('app_notice_type_icon_4002', '4002、续费会员成功')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_type_icon_4002', ''));
                    $form->width(2)->image('app_notice_type_icon_4003', '4003、开通会员成功')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_type_icon_4003', ''));
                    $form->width(2)->image('app_notice_type_icon_4004', '4004、用户新增了粉丝')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_type_icon_4004', ''));
                    $form->width(2)->image('app_notice_type_icon_4005', '4005、认证结果通知')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_type_icon_4005', ''));
                    $form->width(2)->image('app_notice_type_icon_4006', '4006、反馈处理通知')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_type_icon_4006', ''));
                    $form->width(2)->image('app_notice_type_icon_4007', '4007、自动关注圈子')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_type_icon_4007', ''));
                    $form->width(2)->image('app_notice_type_icon_4008', '4008、账号注销取消通知')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_type_icon_4008', ''));
                    $form->width(2)->image('app_notice_type_icon_4009', '4009、用户被笔记@')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_type_icon_4009', ''));
                    $form->width(2)->image('app_notice_type_icon_4010', '4010、用户被评论@')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_type_icon_4010', ''));
                    $form->width(2)->image('app_notice_type_icon_4011', '4011、学生认证结果')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_type_icon_4011', ''));
                });

                $form->divider();
                $form->row(function ($form) {
                    $form->html(function () {
                        return '';
                    }, '<b>五、圈子相关</b>');
                });

                $form->row(function ($form) {
                    $form->width(2)->image('app_notice_type_icon_5001', '5001、创建圈子审核通知')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_type_icon_5001', ''));
                    $form->width(2)->image('app_notice_type_icon_5002', '5002、创建圈子收获粉丝')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_type_icon_5002', ''));
                });

                $form->divider();
                $form->row(function ($form) {
                    $form->html(function () {
                        return '';
                    }, '<b>六、商品相关</b>');
                });

                $form->row(function ($form) {
                    $form->width(2)->image('app_notice_type_icon_6001', '6001、商品发货通知')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_type_icon_6001', ''));
                    $form->width(2)->image('app_notice_type_icon_6002', '6002、商品售后通知')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_type_icon_6002', ''));
                    $form->width(2)->image('app_notice_type_icon_6003', '6003、商品自动确认收货通知')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_type_icon_6003', ''));
                    $form->width(2)->image('app_notice_type_icon_6004', '6004、店铺审核结果')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_type_icon_6004', ''));
                    $form->width(2)->image('app_notice_type_icon_6005', '6005、店铺保证金变动')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_type_icon_6005', ''));
                    $form->width(2)->image('app_notice_type_icon_6006', '6006、商家新订单')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_type_icon_6006', ''));
                });

                $form->divider();
                $form->row(function ($form) {
                    $form->html(function () {
                        return '';
                    }, '<b>七、金融相关</b>');
                });
                $form->row(function ($form) {
                    $form->width(2)->image('app_notice_type_icon_7001', '7001、提现到账通知')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_type_icon_7001', ''));
                    $form->width(2)->image('app_notice_type_icon_7002', '7002、提现异常通知')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_type_icon_7002', ''));
                    $form->width(2)->image('app_notice_type_icon_7003', '7003、金币到账通知')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_type_icon_7003', ''));
                    $form->width(2)->image('app_notice_type_icon_7004', '7004、'.env('circle_user_call', '圈主').'分成奖励')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_type_icon_7004', ''));
                    $form->width(2)->image('app_notice_type_icon_7005', '7005、余额变动提醒')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_type_icon_7005', ''));
                });

                $form->divider();
                $form->row(function ($form) {
                    $form->html(function () {
                        return '';
                    }, '<b>七、选票相关</b>');
                });
                $form->row(function ($form) {
                    $form->width(2)->image('app_notice_type_icon_8001', '8001、创建选票审核结果')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_type_icon_8001', ''));
                    $form->width(2)->image('app_notice_type_icon_8002', '8002、报名选票选手审核')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_type_icon_8002', ''));
                });
                $form->divider();
                $form->row(function ($form) {
                    $form->html(function () {
                        return '';
                    }, '<b>七、组局相关</b>');
                });
                $form->row(function ($form) {
                    $form->width(2)->image('app_notice_type_icon_9001', '9001、创建俱乐部审核结果')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_type_icon_9001', ''));
                    $form->width(2)->image('app_notice_type_icon_9002', '9002、组局活动审核结果')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_type_icon_9002', ''));
                    $form->width(2)->image('app_notice_type_icon_9003', '9003、组局活动即将开始')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_type_icon_9003', ''));
                    $form->width(2)->image('app_notice_type_icon_9004', '9004、组局活动已结束，可上传图集')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_type_icon_9004', ''));
                    $form->width(2)->image('app_notice_type_icon_9005', '9005、参与的组局活动被下架')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('app_notice_type_icon_9005', ''));
                });
            });
        }


        $form->action('settings/action/pagenotice');
        return $form;
    }

    public function pagenotice(Request $request){
        global $__MINI_GLOBAL_TENANT_ID__;
        SiteUtils::forget_config_data();

        if($__MINI_GLOBAL_TENANT_ID__ === 0){
            if(!_empty_(Settings::get('mp_app_secret', ''))){
                Settings::set('app_notice_mp_follow', $request->input('app_notice_mp_follow'), true);
            }else{
                Settings::set('app_notice_mp_follow', 0, true);
            }
            Settings::set('app_notice_img_style', $request->input('app_notice_img_style'), true);

            Settings::set('template_message_notice_id', $request->input('template_message_notice_id'), true);

            $template_message_notice_black_list = $request->input('template_message_notice_black_list');
            if(_empty_(end($template_message_notice_black_list))){
                array_pop($template_message_notice_black_list);
            }
            $template_message_notice_black_list_ = [];
            if(!_empty_($template_message_notice_black_list)){
                _update_env([
                    'TEMPLATE_MESSAGE_NOTICE_BLACK_LIST' => implode(',', $template_message_notice_black_list),
                ], [], 1);
                foreach ($template_message_notice_black_list as $notice_type){
                    $template_message_notice_black_list_[] = (string)$notice_type;
                }
            }else{
                _update_env([
                    'TEMPLATE_MESSAGE_NOTICE_BLACK_LIST' => '',
                ], [], 1);
            }
            Settings::set('template_message_notice_black_list', $template_message_notice_black_list_, true);



            Settings::set('mini_template_message_comment_add', $request->input('mini_template_message_comment_add'), true);
            Settings::set('mini_template_message_comment_reply', $request->input('mini_template_message_comment_reply'), true);
            Settings::set('mini_template_message_exceptional', $request->input('mini_template_message_exceptional'), true);
            Settings::set('mini_template_message_beliked', $request->input('mini_template_message_beliked'), true);
            Settings::set('mini_template_message_withdrawal', $request->input('mini_template_message_withdrawal'), true);
            Settings::set('mini_template_message_authentication', $request->input('mini_template_message_authentication'), true);

            Settings::set('app_notice_img_system', $request->input('app_notice_img_system'), true);
            Settings::set('app_notice_img_like', $request->input('app_notice_img_like'), true);
            Settings::set('app_notice_img_comment', $request->input('app_notice_img_comment'), true);
            Settings::set('app_notice_img_servicer', $request->input('app_notice_img_servicer'), true);
            Settings::set('app_notice_img_circle', $request->input('app_notice_img_circle'), true);


            Settings::set('app_notice_assistant_user', $request->input('app_notice_assistant_user'), true);
            Settings::set('app_notice_review_user', $request->input('app_notice_review_user'), true);


            Settings::set('app_notice_type_icon_1000', $request->input('app_notice_type_icon_1000'), true);
            Settings::set('app_notice_type_icon_1001', $request->input('app_notice_type_icon_1001'), true);
            Settings::set('app_notice_type_icon_1002', $request->input('app_notice_type_icon_1002'), true);
            Settings::set('app_notice_type_icon_1003', $request->input('app_notice_type_icon_1003'), true);

            Settings::set('app_notice_type_icon_2001', $request->input('app_notice_type_icon_2001'), true);
            Settings::set('app_notice_type_icon_2002', $request->input('app_notice_type_icon_2002'), true);
            Settings::set('app_notice_type_icon_2003', $request->input('app_notice_type_icon_2003'), true);
            Settings::set('app_notice_type_icon_2004', $request->input('app_notice_type_icon_2004'), true);
            Settings::set('app_notice_type_icon_2005', $request->input('app_notice_type_icon_2005'), true);
            Settings::set('app_notice_type_icon_2006', $request->input('app_notice_type_icon_2006'), true);
            Settings::set('app_notice_type_icon_2007', $request->input('app_notice_type_icon_2007'), true);
            Settings::set('app_notice_type_icon_2008', $request->input('app_notice_type_icon_2008'), true);


            Settings::set('app_notice_type_icon_3001', $request->input('app_notice_type_icon_3001'), true);
            Settings::set('app_notice_type_icon_3002', $request->input('app_notice_type_icon_3002'), true);
            Settings::set('app_notice_type_icon_3003', $request->input('app_notice_type_icon_3003'), true);

            Settings::set('app_notice_type_icon_4001', $request->input('app_notice_type_icon_4001'), true);
            Settings::set('app_notice_type_icon_4002', $request->input('app_notice_type_icon_4002'), true);
            Settings::set('app_notice_type_icon_4003', $request->input('app_notice_type_icon_4003'), true);
            Settings::set('app_notice_type_icon_4004', $request->input('app_notice_type_icon_4004'), true);
            Settings::set('app_notice_type_icon_4005', $request->input('app_notice_type_icon_4005'), true);
            Settings::set('app_notice_type_icon_4006', $request->input('app_notice_type_icon_4006'), true);
            Settings::set('app_notice_type_icon_4007', $request->input('app_notice_type_icon_4007'), true);
            Settings::set('app_notice_type_icon_4008', $request->input('app_notice_type_icon_4008'), true);
            Settings::set('app_notice_type_icon_4009', $request->input('app_notice_type_icon_4009'), true);
            Settings::set('app_notice_type_icon_4010', $request->input('app_notice_type_icon_4010'), true);
            Settings::set('app_notice_type_icon_4011', $request->input('app_notice_type_icon_4011'), true);

            Settings::set('app_notice_type_icon_5001', $request->input('app_notice_type_icon_5001'), true);
            Settings::set('app_notice_type_icon_5002', $request->input('app_notice_type_icon_5002'), true);
            Settings::set('app_notice_type_icon_6001', $request->input('app_notice_type_icon_6001'), true);
            Settings::set('app_notice_type_icon_6002', $request->input('app_notice_type_icon_6002'), true);
            Settings::set('app_notice_type_icon_6003', $request->input('app_notice_type_icon_6003'), true);
            Settings::set('app_notice_type_icon_6004', $request->input('app_notice_type_icon_6004'), true);
            Settings::set('app_notice_type_icon_6005', $request->input('app_notice_type_icon_6005'), true);
            Settings::set('app_notice_type_icon_6006', $request->input('app_notice_type_icon_6006'), true);

            Settings::set('app_notice_type_icon_7001', $request->input('app_notice_type_icon_7001'), true);
            Settings::set('app_notice_type_icon_7002', $request->input('app_notice_type_icon_7002'), true);
            Settings::set('app_notice_type_icon_7003', $request->input('app_notice_type_icon_7003'), true);
            Settings::set('app_notice_type_icon_7004', $request->input('app_notice_type_icon_7004'), true);
            Settings::set('app_notice_type_icon_7005', $request->input('app_notice_type_icon_7005'), true);

            Settings::set('app_notice_type_icon_8001', $request->input('app_notice_type_icon_8001'), true);
            Settings::set('app_notice_type_icon_8002', $request->input('app_notice_type_icon_8002'), true);

            Settings::set('app_notice_type_icon_9001', $request->input('app_notice_type_icon_9001'), true);
            Settings::set('app_notice_type_icon_9002', $request->input('app_notice_type_icon_9002'), true);
            Settings::set('app_notice_type_icon_9003', $request->input('app_notice_type_icon_9003'), true);
            Settings::set('app_notice_type_icon_9004', $request->input('app_notice_type_icon_9004'), true);
            Settings::set('app_notice_type_icon_9005', $request->input('app_notice_type_icon_9005'), true);
        }

        Settings::set('app_notice_assistant_first', $request->input('app_notice_assistant_first'), true, true);

        Settings::set('app_notice_img_servicer_mp_servicer', $request->input('app_notice_img_servicer_mp_servicer') == 1 ? 1 : 0, true, true);
        Settings::set('app_notice_img_servicer_target_type', $request->input('app_notice_img_servicer_target_type'), true, true);
        Settings::set('app_notice_img_servicer_target_id', $request->input('app_notice_img_servicer_target_id'), true, true);

        $__global_config_version__ = Settings::get('__global_config_version__', 1) + 1;
        Settings::set('__global_config_version__', $__global_config_version__);
        GatewayUtils::success('all', 13, [ 'version' => $__global_config_version__, 'file' => basename(__FILE__) ]);
        return $this->response()->success('成功！');
    }

}
